<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">

	<title>TFWeakTimer Class Reference</title>

	<link rel="stylesheet" href="../css/style.css">
	<meta name="viewport" content="initial-scale=1, maximum-scale=1.4">
	<meta name="generator" content="appledoc 2.2.1 (build 1334)">
</head>
<body class="appledoc">
	<header>
		<div class="container" class="hide-in-xcode">
			
			<h1 id="library-title">
				<a href="../index.html">TFFoundation </a>
			</h1>

			<p id="developer-home">
				<a href="../index.html">“Timeface”</a>
			</p>
			
		</div>
	</header>

	<aside>
		<div class="container">
			<nav>
				<ul id="header-buttons" role="toolbar">
					<li><a href="../index.html">Index</a></li>
<li><a href="../hierarchy.html">Hierarchy</a></li>

					<li id="on-this-page" role="navigation">
						<label>
							On This Page

							<div class="chevron">
								<div class="chevy chevron-left"></div>
								<div class="chevy chevron-right"></div>
							</div>

							<select id="jump-to">
	<option value="top">Jump To&#133;</option>
	
	<option value="overview">Overview</option>
	

	
	
	<option value="tasks">Tasks</option>
	
	

	
	
	<optgroup label="Properties">
		
		<option value="//api/name/tolerance">tolerance</option>
		
	</optgroup>
	

	
	<optgroup label="Class Methods">
		
		<option value="//api/name/scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:">+ scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:</option>
		
	</optgroup>
	

	
	<optgroup label="Instance Methods">
		
		<option value="//api/name/fire">- fire</option>
		
		<option value="//api/name/initWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:">- initWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:</option>
		
		<option value="//api/name/invalidate">- invalidate</option>
		
		<option value="//api/name/schedule">- schedule</option>
		
		<option value="//api/name/userInfo">- userInfo</option>
		
	</optgroup>
	
	
</select>
						</label>
					</li>
				</ul>
			</nav>
		</div>
	</aside>

	<article>
		<div id="overview_contents" class="container">
			<div id="content">
				<main role="main">
					<h1 class="title">TFWeakTimer Class Reference</h1>

					
					<div class="section section-specification"><table cellspacing="0"><tbody>
						<tr>
	<th>Inherits from</th>
	<td>NSObject</td>
</tr><tr>
	<th>Declared in</th>
	<td>TFWeakTimer.h<br />TFWeakTimer.m</td>
</tr>
						</tbody></table></div>
					

                    
					
					<div class="section section-overview">
						<a title="Overview" name="overview"></a>
						<h2 class="subtitle subtitle-overview">Overview</h2>
						<p><code>TFWeakTimer</code> behaves similar to an <code>NSTimer</code> but doesn&rsquo;t retain the target.
This timer is implemented using GCD, so you can <a href="#//api/name/schedule">schedule</a> and un<a href="#//api/name/schedule">schedule</a> it on arbitrary queues (unlike regular NSTimers!)</p>
					</div>
					
					

					
					
					<div class="section section-tasks">
						<a title="Tasks" name="tasks"></a>
						

						
						

						<div class="task-list">
							<div class="section-method">
	<a name="//api/name/initWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:" title="initWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:"></a>
	<h3 class="method-title"><code><a href="#//api/name/initWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:">&ndash;&nbsp;initWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:</a></code>
</h3>

	<div class="method-info">
		<div class="pointy-thing"></div>

		<div class="method-info-container">
			
			
			<div class="method-subsection brief-description">
				<p>Creates a <a href="#//api/name/timer">timer</a> with the specified parameters and waits for a call to <a href="#//api/name/schedule"><code>schedule</code></a> to start ticking.</p>
			</div>
			
		    

			<div class="method-subsection method-declaration"><code>- (id)initWithTimeInterval:(NSTimeInterval)<em>timeInterval</em> target:(id)<em>target</em> selector:(SEL)<em>selector</em> userInfo:(id)<em>userInfo</em> repeats:(BOOL)<em>repeats</em> dispatchQueue:(dispatch_queue_t)<em>dispatchQueue</em></code></div>

		    
			
			<div class="method-subsection arguments-section parameters">
				<h4 class="method-subtitle parameter-title">Parameters</h4>
				<table class="argument-def parameter-def">
				
					<tr>
						<th scope="row" class="argument-name"><code>timeInterval</code></th>
						<td><p>how frequently <a href="#//api/name/selector"><code>selector</code></a> will be invoked on <a href="#//api/name/target"><code>target</code></a>. If the <a href="#//api/name/timer">timer</a> doens&rsquo;t repeat, it will only be invoked once, approximately <a href="#//api/name/timeInterval"><code>timeInterval</code></a> seconds from the time you call this method.</p></td>
					</tr>
				
					<tr>
						<th scope="row" class="argument-name"><code>target</code></th>
						<td><p><a href="#//api/name/target">target</a></p></td>
					</tr>
				
					<tr>
						<th scope="row" class="argument-name"><code>selector</code></th>
						<td><p><a href="#//api/name/selector">selector</a></p></td>
					</tr>
				
					<tr>
						<th scope="row" class="argument-name"><code>userInfo</code></th>
						<td><p>user info</p></td>
					</tr>
				
					<tr>
						<th scope="row" class="argument-name"><code>repeats</code></th>
						<td><p>if <code>YES</code>, <a href="#//api/name/selector"><code>selector</code></a> will be invoked on <a href="#//api/name/target"><code>target</code></a> until the <code>TFWeakTimer</code> object is deallocated or until you call <a href="#//api/name/invalidate"><code>invalidate</code></a>. If <code>NO</code>, it will only be invoked once.</p></td>
					</tr>
				
					<tr>
						<th scope="row" class="argument-name"><code>dispatchQueue</code></th>
						<td><p>the queue where the delegate method will be dispatched. It can be either a serial or concurrent queue.</p></td>
					</tr>
				
				</table>
			</div>
			

			
			<div class="method-subsection return">
				<h4 class="method-subtitle parameter-title">Return Value</h4>
				<p>TFWeakTimer</p>
			</div>
			

			

			
			<div class="method-subsection discussion-section">
				<h4 class="method-subtitle">Discussion</h4>
				<p>Creates a <a href="#//api/name/timer">timer</a> with the specified parameters and waits for a call to <a href="#//api/name/schedule"><code>schedule</code></a> to start ticking.</p><div class="note"><p><strong>Note:</strong> It&rsquo;s safe to retain the returned <a href="#//api/name/timer">timer</a> by the object that is also the <a href="#//api/name/target">target</a> or the provided <code>dispatchQueue</code>.</p></div>
			</div>
			

			

			

			
			<div class="method-subsection declared-in-section">
				<h4 class="method-subtitle">Declared In</h4>
				<p><code class="declared-in-ref">TFWeakTimer.h</code></p>
			</div>
			
			
		</div>
	</div>
</div><div class="section-method">
	<a name="//api/name/scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:" title="scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:"></a>
	<h3 class="method-title"><code><a href="#//api/name/scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:">+&nbsp;scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:dispatchQueue:</a></code>
</h3>

	<div class="method-info">
		<div class="pointy-thing"></div>

		<div class="method-info-container">
			
			
			<div class="method-subsection brief-description">
				<p>Creates an <code>TFWeakTimer</code> object and schedules it to start ticking inmediately.</p>
			</div>
			
		    

			<div class="method-subsection method-declaration"><code>+ (instancetype)scheduledTimerWithTimeInterval:(NSTimeInterval)<em>timeInterval</em> target:(id)<em>target</em> selector:(SEL)<em>selector</em> userInfo:(id)<em>userInfo</em> repeats:(BOOL)<em>repeats</em> dispatchQueue:(dispatch_queue_t)<em>dispatchQueue</em></code></div>

		    
			
			<div class="method-subsection arguments-section parameters">
				<h4 class="method-subtitle parameter-title">Parameters</h4>
				<table class="argument-def parameter-def">
				
					<tr>
						<th scope="row" class="argument-name"><code>timeInterval</code></th>
						<td><p>how frequently <a href="#//api/name/selector"><code>selector</code></a> will be invoked on <a href="#//api/name/target"><code>target</code></a>. If the <a href="#//api/name/timer">timer</a> doens&rsquo;t repeat, it will only be invoked once, approximately <a href="#//api/name/timeInterval"><code>timeInterval</code></a> seconds from the time you call this method.</p></td>
					</tr>
				
					<tr>
						<th scope="row" class="argument-name"><code>target</code></th>
						<td><p><a href="#//api/name/target">target</a></p></td>
					</tr>
				
					<tr>
						<th scope="row" class="argument-name"><code>selector</code></th>
						<td><p><a href="#//api/name/selector">selector</a></p></td>
					</tr>
				
					<tr>
						<th scope="row" class="argument-name"><code>userInfo</code></th>
						<td><p>user info</p></td>
					</tr>
				
					<tr>
						<th scope="row" class="argument-name"><code>repeats</code></th>
						<td><p>if <code>YES</code>, <a href="#//api/name/selector"><code>selector</code></a> will be invoked on <a href="#//api/name/target"><code>target</code></a> until the <code>TFWeakTimer</code> object is deallocated or until you call <a href="#//api/name/invalidate"><code>invalidate</code></a>. If <code>NO</code>, it will only be invoked once.</p></td>
					</tr>
				
					<tr>
						<th scope="row" class="argument-name"><code>dispatchQueue</code></th>
						<td><p>the queue where the delegate method will be dispatched. It can be either a serial or concurrent queue.</p></td>
					</tr>
				
				</table>
			</div>
			

			
			<div class="method-subsection return">
				<h4 class="method-subtitle parameter-title">Return Value</h4>
				<p>TFWeakTimer</p>
			</div>
			

			

			
			<div class="method-subsection discussion-section">
				<h4 class="method-subtitle">Discussion</h4>
				<p>Creates an <code>TFWeakTimer</code> object and schedules it to start ticking inmediately.</p>
			</div>
			

			

			

			
			<div class="method-subsection declared-in-section">
				<h4 class="method-subtitle">Declared In</h4>
				<p><code class="declared-in-ref">TFWeakTimer.h</code></p>
			</div>
			
			
		</div>
	</div>
</div><div class="section-method">
	<a name="//api/name/schedule" title="schedule"></a>
	<h3 class="method-title"><code><a href="#//api/name/schedule">&ndash;&nbsp;schedule</a></code>
</h3>

	<div class="method-info">
		<div class="pointy-thing"></div>

		<div class="method-info-container">
			
			
			<div class="method-subsection brief-description">
				<p>Starts the <a href="#//api/name/timer">timer</a> if it hadn&rsquo;t been schedule yet.</p>
			</div>
			
		    

			<div class="method-subsection method-declaration"><code>- (void)schedule</code></div>

		    
			

			

			

			
			<div class="method-subsection discussion-section">
				<h4 class="method-subtitle">Discussion</h4>
				<p>Starts the <a href="#//api/name/timer">timer</a> if it hadn&rsquo;t been schedule yet.</p><div class="warning"><p><strong>Warning:</strong> calling this method on an already scheduled <a href="#//api/name/timer">timer</a> results in undefined behavior.</p></div>
			</div>
			

			

			

			
			<div class="method-subsection declared-in-section">
				<h4 class="method-subtitle">Declared In</h4>
				<p><code class="declared-in-ref">TFWeakTimer.h</code></p>
			</div>
			
			
		</div>
	</div>
</div><div class="section-method">
	<a name="//api/name/tolerance" title="tolerance"></a>
	<h3 class="method-title"><code><a href="#//api/name/tolerance">&nbsp;&nbsp;tolerance</a></code>
</h3>

	<div class="method-info">
		<div class="pointy-thing"></div>

		<div class="method-info-container">
			
			
			<div class="method-subsection brief-description">
				<ul>
<li>Sets the amount of time after the scheduled <a href="#//api/name/fire">fire</a> date that the <a href="#//api/name/timer">timer</a> may <a href="#//api/name/fire">fire</a> to the given interval.</li>
<li>@discussion Setting a tolerance for a <a href="#//api/name/timer">timer</a> allows it to <a href="#//api/name/fire">fire</a> later than the scheduled <a href="#//api/name/fire">fire</a> date, improving the ability of the system to optimize for increased power savings and responsiveness. The <a href="#//api/name/timer">timer</a> may <a href="#//api/name/fire">fire</a> at any time between its scheduled <a href="#//api/name/fire">fire</a> date and the scheduled <a href="#//api/name/fire">fire</a> date plus the tolerance. The <a href="#//api/name/timer">timer</a> will not <a href="#//api/name/fire">fire</a> before the scheduled <a href="#//api/name/fire">fire</a> date. For repeating timers, the next <a href="#//api/name/fire">fire</a> date is calculated from the original <a href="#//api/name/fire">fire</a> date regardless of tolerance applied at individual <a href="#//api/name/fire">fire</a> times, to avoid drift. The default value is zero, which means no additional tolerance is applied. The system reserves the right to apply a small amount of tolerance to certain timers regardless of the value of this property.
As the user of the <a href="#//api/name/timer">timer</a>, you will have the best idea of what an appropriate tolerance for a <a href="#//api/name/timer">timer</a> may be. A general rule of thumb, though, is to set the tolerance to at least 10% of the interval, for a repeating <a href="#//api/name/timer">timer</a>. Even a small amount of tolerance will have a significant positive impact on the power usage of your application. The system may put a maximum value of the tolerance.</li>
</ul>

			</div>
			
		    

			<div class="method-subsection method-declaration"><code>@property (atomic, assign) NSTimeInterval tolerance</code></div>

		    
			

			

			

			
			<div class="method-subsection discussion-section">
				<h4 class="method-subtitle">Discussion</h4>
				<ul>
<li>Sets the amount of time after the scheduled <a href="#//api/name/fire">fire</a> date that the <a href="#//api/name/timer">timer</a> may <a href="#//api/name/fire">fire</a> to the given interval.</li>
<li>@discussion Setting a tolerance for a <a href="#//api/name/timer">timer</a> allows it to <a href="#//api/name/fire">fire</a> later than the scheduled <a href="#//api/name/fire">fire</a> date, improving the ability of the system to optimize for increased power savings and responsiveness. The <a href="#//api/name/timer">timer</a> may <a href="#//api/name/fire">fire</a> at any time between its scheduled <a href="#//api/name/fire">fire</a> date and the scheduled <a href="#//api/name/fire">fire</a> date plus the tolerance. The <a href="#//api/name/timer">timer</a> will not <a href="#//api/name/fire">fire</a> before the scheduled <a href="#//api/name/fire">fire</a> date. For repeating timers, the next <a href="#//api/name/fire">fire</a> date is calculated from the original <a href="#//api/name/fire">fire</a> date regardless of tolerance applied at individual <a href="#//api/name/fire">fire</a> times, to avoid drift. The default value is zero, which means no additional tolerance is applied. The system reserves the right to apply a small amount of tolerance to certain timers regardless of the value of this property.
As the user of the <a href="#//api/name/timer">timer</a>, you will have the best idea of what an appropriate tolerance for a <a href="#//api/name/timer">timer</a> may be. A general rule of thumb, though, is to set the tolerance to at least 10% of the interval, for a repeating <a href="#//api/name/timer">timer</a>. Even a small amount of tolerance will have a significant positive impact on the power usage of your application. The system may put a maximum value of the tolerance.</li>
</ul>

			</div>
			

			

			

			
			<div class="method-subsection declared-in-section">
				<h4 class="method-subtitle">Declared In</h4>
				<p><code class="declared-in-ref">TFWeakTimer.h</code></p>
			</div>
			
			
		</div>
	</div>
</div><div class="section-method">
	<a name="//api/name/fire" title="fire"></a>
	<h3 class="method-title"><code><a href="#//api/name/fire">&ndash;&nbsp;fire</a></code>
</h3>

	<div class="method-info">
		<div class="pointy-thing"></div>

		<div class="method-info-container">
			
			
			<div class="method-subsection brief-description">
				<p>Causes the <a href="#//api/name/timer">timer</a> to be fired synchronously manually on the queue from which you call this method.
You can use this method to fire a repeating <a href="#//api/name/timer">timer</a> without interrupting its regular firing <a href="#//api/name/schedule">schedule</a>.
If the <a href="#//api/name/timer">timer</a> is non-repeating, it is automatically invalidated after firing, even if its scheduled fire date has not arrived.</p>
			</div>
			
		    

			<div class="method-subsection method-declaration"><code>- (void)fire</code></div>

		    
			

			

			

			
			<div class="method-subsection discussion-section">
				<h4 class="method-subtitle">Discussion</h4>
				<p>Causes the <a href="#//api/name/timer">timer</a> to be fired synchronously manually on the queue from which you call this method.
You can use this method to fire a repeating <a href="#//api/name/timer">timer</a> without interrupting its regular firing <a href="#//api/name/schedule">schedule</a>.
If the <a href="#//api/name/timer">timer</a> is non-repeating, it is automatically invalidated after firing, even if its scheduled fire date has not arrived.</p>
			</div>
			

			

			

			
			<div class="method-subsection declared-in-section">
				<h4 class="method-subtitle">Declared In</h4>
				<p><code class="declared-in-ref">TFWeakTimer.h</code></p>
			</div>
			
			
		</div>
	</div>
</div><div class="section-method">
	<a name="//api/name/invalidate" title="invalidate"></a>
	<h3 class="method-title"><code><a href="#//api/name/invalidate">&ndash;&nbsp;invalidate</a></code>
</h3>

	<div class="method-info">
		<div class="pointy-thing"></div>

		<div class="method-info-container">
			
			
			<div class="method-subsection brief-description">
				<p>You can call this method on repeatable timers in order to stop it from running and trying
to call the delegate method.</p>
			</div>
			
		    

			<div class="method-subsection method-declaration"><code>- (void)invalidate</code></div>

		    
			

			

			

			
			<div class="method-subsection discussion-section">
				<h4 class="method-subtitle">Discussion</h4>
				<p>You can call this method on repeatable timers in order to stop it from running and trying
to call the delegate method.</p><div class="note"><p><strong>Note:</strong> <code>MSWeakTimer</code> won&rsquo;t invoke the <a href="#//api/name/selector"><code>selector</code></a> on <a href="#//api/name/target"><code>target</code></a> again after calling this method.
You can call this method from any queue, it doesn&rsquo;t have to be the queue from where you scheduled it.
Since it doesn&rsquo;t retain the delegate, unlike a regular <code>NSTimer</code>, your <a href="#//api/name/dealloc"><code>dealloc</code></a> method will actually be called
and it&rsquo;s easier to place the <code>invalidate</code> call there, instead of figuring out a safe place to do it.</p></div>
			</div>
			

			

			

			
			<div class="method-subsection declared-in-section">
				<h4 class="method-subtitle">Declared In</h4>
				<p><code class="declared-in-ref">TFWeakTimer.h</code></p>
			</div>
			
			
		</div>
	</div>
</div><div class="section-method">
	<a name="//api/name/userInfo" title="userInfo"></a>
	<h3 class="method-title"><code><a href="#//api/name/userInfo">&ndash;&nbsp;userInfo</a></code>
</h3>

	<div class="method-info">
		<div class="pointy-thing"></div>

		<div class="method-info-container">
			
			
			<div class="method-subsection brief-description">
				<p>return current user info.</p>
			</div>
			
		    

			<div class="method-subsection method-declaration"><code>- (id)userInfo</code></div>

		    
			

			
			<div class="method-subsection return">
				<h4 class="method-subtitle parameter-title">Return Value</h4>
				<p>id</p>
			</div>
			

			

			
			<div class="method-subsection discussion-section">
				<h4 class="method-subtitle">Discussion</h4>
				<p>return current user info.</p>
			</div>
			

			

			

			
			<div class="method-subsection declared-in-section">
				<h4 class="method-subtitle">Declared In</h4>
				<p><code class="declared-in-ref">TFWeakTimer.h</code></p>
			</div>
			
			
		</div>
	</div>
</div>
						</div>
						
					</div>
					
					

                    
                    
          
				</main>

				<footer>
					<div class="footer-copyright">
						
						<p class="copyright">Copyright &copy; 2017 “Timeface”. All rights reserved. Updated: 2017-08-17</p>
						
						
						<p class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.2.1 (build 1334)</a>.</p>
						
					</div>
				</footer>
			</div>
		</div>
	</article>

	<script src="../js/script.js"></script>
</body>
</html>